% make_coastSalish_tide_track.m
%
% Makes a track beginning off Charleston, OR, that goes into Juan de Fuca
% Strait and then branches into both Puget Sound and the Strait of Georgia.
%
% The track is useful for plotting tidal amplitudes and phases as a
% function of along-track distance.
%
%
% OUTPUT:
%   coastSalish_tide_track.mat  with variables
%
%       track_PS  -  [lon lat] pairs of track along coast into Puget Sound
%       track_SG  -  [lon lat] pairs of track along coast into Strait of Georgia
%
%
% R. McCabe 06/2014


%% Flags/switches
savematfile = 0;
plotsamplefigure = 1;


%% Set the appropriate paths
addpath('../../alpha/');
Tdir = toolstart;
addpath(genpath([Tdir.tools 'validation_tools']));


%% Define some transects from the coast into Puget Sound and Strait of Georgia
% Transect from Charleston, OR, along the coast to Neah Bay, WA, and into
% Juan de Fuca Strait -- made using ginput with a coastline plot
transect_coastJdF = [-124.5133   43.1272
 -124.3610   43.7189
 -124.1896   44.6063
 -124.1135   45.0950
 -124.0373   45.5581
 -124.1135   46.2140
 -124.1706   46.6770
 -124.2658   46.9214
 -124.4181   47.3715
 -124.5323   47.6416
 -124.7417   47.8989
 -124.8179   48.1818
 -124.7798   48.4133
 -124.7036   48.4905
 -124.1706   48.3361
 -123.7518   48.2590
 -123.5424   48.2461
 -123.3710   48.2847
 -123.0855   48.3104
 -122.9141   48.3233];

% Transect from Juan de Fuca Strait into Puget Sound. Also made using
% ginput with a coastline plot
transect_PS = [-122.7909   48.1828
 -122.6552   48.1167
 -122.6331   48.0250
 -122.5953   47.9632
 -122.4880   47.9163
 -122.4249   47.8481
 -122.4375   47.7437
 -122.4596   47.6585
 -122.4470   47.5796
 -122.4186   47.5007
 -122.3997   47.4389
 -122.3555   47.3814
 -122.3997   47.3473
 -122.4659   47.3196
 -122.4975   47.3153
 -122.5448   47.3345
 -122.5606   47.3217
 -122.5448   47.3025
 -122.5416   47.2855
 -122.5669   47.2535
 -122.5953   47.2045
 -122.6520   47.1725
 -122.6710   47.1320
 -122.7088   47.1128
 -122.7467   47.1299
 -122.7814   47.1576
 -122.8193   47.1938];

% Transect from Juan de Fuca Strait into the Strait of Georgia.  Also made
% using ginput with a coastline plot
transect_SG = [-122.9884   48.4346
 -123.1179   48.4589
 -123.1898   48.5220
 -123.2401   48.5949
 -123.2617   48.6969
 -123.2329   48.7164
 -123.1322   48.7212
 -122.9956   48.7455
 -122.9812   48.8573
 -123.2617   48.9982
 -123.4846   49.1877
 -123.7723   49.2946
 -124.0384   49.3820
 -124.3045   49.4063
 -124.4843   49.4695
 -124.5562   49.5812
 -124.7863   49.7367
 -125.0933   49.9100
 -125.2110   49.9974
 -125.2671   50.0819];

% Combine coast, JdF, and Puget Sound into a master Puget Sound transect
transect_PS = [transect_coastJdF; transect_PS];
PS_lon = transect_PS(:,1);
PS_lat = transect_PS(:,2);

% Combine coast, JdF, and Georgia Strait into a master Georgia Strait transect
transect_SG = [transect_coastJdF; transect_SG];
SG_lon = transect_SG(:,1);
SG_lat = transect_SG(:,2);
clear transect_coastJdF transect_PS transect_SG

% Make the Puget Sound transect much finer scale
transect_PSlon = [];
transect_PSlat = [];
for ii = 1:length(PS_lat)-1
    transect_PSlon = [transect_PSlon, linspace(PS_lon(ii),PS_lon(ii+1),10)];
    transect_PSlat = [transect_PSlat, linspace(PS_lat(ii),PS_lat(ii+1),10)];
end
clear ii PS_lon PS_lat
transect_PSlon = transect_PSlon';
transect_PSlat = transect_PSlat';
AA = [transect_PSlon transect_PSlat];
AAu = unique(AA,'rows','stable');
transect_PSlon = AAu(:,1);
transect_PSlat = AAu(:,2);
clear AA AAu

% Make the Strait of Georgia transect much finer scale
transect_SGlon = [];
transect_SGlat = [];
for ii = 1:length(SG_lat)-1
    transect_SGlon = [transect_SGlon, linspace(SG_lon(ii),SG_lon(ii+1),10)];
    transect_SGlat = [transect_SGlat, linspace(SG_lat(ii),SG_lat(ii+1),10)];
end
clear ii SG_lon SG_lat
transect_SGlon = transect_SGlon';
transect_SGlat = transect_SGlat';
AA = [transect_SGlon transect_SGlat];
AAu = unique(AA,'rows','stable');
transect_SGlon = AAu(:,1);
transect_SGlat = AAu(:,2);
clear AA AAu


%% Rename
track_PS = [transect_PSlon, transect_PSlat];
track_SG = [transect_SGlon, transect_SGlat];
clear transect_PSlon transect_PSlat transect_SGlon transect_SGlat


%% Save a .mat file
if savematfile
    save coastSalish_tide_track.mat track_PS track_SG
end


%% Plot a sample figure of the track
if plotsamplefigure
    figure; hold on;
    set(gcf,'position',[1300 290 400 630]);
    plot_WAcoast('all','color',0.6*[1 1 1]);
    axis([-127 -122 43 50.5]);
    Z_dar;
    
    xlabel('Longitude [deg]','fontsize',12);
    ylabel('Latitude [deg]','fontsize',12);
    
    % Plot the PS track
    plot(track_PS(:,1),track_PS(:,2),'m-');
    % Plot the PS track
    plot(track_SG(:,1),track_SG(:,2),'m-');
    
end

